package cn.bone.quartz.demo1;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * Created by superbone on 2016/10/10.
 */
public class QuartzTest {

    public static void main(String[] args) throws SchedulerException {

        SchedulerFactory schedulerFactory = new StdSchedulerFactory();
        Scheduler scheduler = schedulerFactory.getScheduler();

        JobDetail job = JobBuilder.newJob(HelloJob.class)
                .withIdentity("myJob","group1")
                .build();
        Trigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("myTrigger","group2")
                .startNow()
                .withSchedule(
                        SimpleScheduleBuilder.simpleSchedule()
                        .withIntervalInSeconds(5).repeatForever())
                .build();
        scheduler.scheduleJob(job,trigger);
        scheduler.start();
        try {
            Thread.sleep(100000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        scheduler.shutdown();
    }
}
